﻿using System;
using System.Collections.Generic;
using UnityEngine;

// Token: 0x0200016F RID: 367
public class FemaleGuideCustom : MonoBehaviour
{
	// Token: 0x06000992 RID: 2450 RVA: 0x000384D0 File Offset: 0x000366D0
	private void Start()
	{
	}

	// Token: 0x06000993 RID: 2451 RVA: 0x000384D4 File Offset: 0x000366D4
	private void Update()
	{
		if (!this.setuped)
		{
			this.Setup();
			this.setuped = true;
		}
	}

	// Token: 0x06000994 RID: 2452 RVA: 0x000384F0 File Offset: 0x000366F0
	private void Setup()
	{
		foreach (FemaleGuideCustom.MovePoint movePoint in this.facePoints)
		{
			movePoint.Setup(this.guidesManager, this.female.head, this.female.transform);
		}
		foreach (FemaleGuideCustom.MovePoint movePoint2 in this.bodyPoints)
		{
			movePoint2.Setup(this.guidesManager, this.female.body, this.female.transform);
		}
	}

	// Token: 0x0400096B RID: 2411
	public Female female;

	// Token: 0x0400096C RID: 2412
	public GuidesManager guidesManager;

	// Token: 0x0400096D RID: 2413
	public FemaleGuideCustom.MovePoint[] facePoints;

	// Token: 0x0400096E RID: 2414
	public FemaleGuideCustom.MovePoint[] bodyPoints;

	// Token: 0x0400096F RID: 2415
	private bool setuped;

	// Token: 0x02000170 RID: 368
	[Serializable]
	public class MoveParam
	{
		// Token: 0x1700012B RID: 299
		// (get) Token: 0x06000996 RID: 2454 RVA: 0x00038598 File Offset: 0x00036798
		// (set) Token: 0x06000997 RID: 2455 RVA: 0x000385A0 File Offset: 0x000367A0
		public float Rate { get; private set; }

		// Token: 0x1700012C RID: 300
		// (get) Token: 0x06000998 RID: 2456 RVA: 0x000385AC File Offset: 0x000367AC
		// (set) Token: 0x06000999 RID: 2457 RVA: 0x000385B4 File Offset: 0x000367B4
		public FemaleGuideCustom.MoveParam.TYPE Type { get; private set; }

		// Token: 0x0600099A RID: 2458 RVA: 0x000385C0 File Offset: 0x000367C0
		public void Setup()
		{
			this.CalcRate();
			if (this.drive == FemaleGuideCustom.MoveParam.DRIVE.POS_X || this.drive == FemaleGuideCustom.MoveParam.DRIVE.POS_Y || this.drive == FemaleGuideCustom.MoveParam.DRIVE.POS_Z)
			{
				this.Type = FemaleGuideCustom.MoveParam.TYPE.POS;
			}
			if (this.drive == FemaleGuideCustom.MoveParam.DRIVE.ROT_X || this.drive == FemaleGuideCustom.MoveParam.DRIVE.ROT_Y || this.drive == FemaleGuideCustom.MoveParam.DRIVE.ROT_Z)
			{
				this.Type = FemaleGuideCustom.MoveParam.TYPE.ROT;
			}
			if (this.drive == FemaleGuideCustom.MoveParam.DRIVE.SCL_X || this.drive == FemaleGuideCustom.MoveParam.DRIVE.SCL_Y || this.drive == FemaleGuideCustom.MoveParam.DRIVE.SCL_Z)
			{
				this.Type = FemaleGuideCustom.MoveParam.TYPE.SCL;
			}
		}

		// Token: 0x0600099B RID: 2459 RVA: 0x00038654 File Offset: 0x00036854
		private void CalcRate()
		{
			if (this.val != 0f)
			{
				this.Rate = 1f / this.val;
			}
			else
			{
				this.Rate = 0f;
			}
		}

		// Token: 0x0600099C RID: 2460 RVA: 0x00038688 File Offset: 0x00036888
		public void CustomMovePos(CharaShapeCustomBase custom, Vector3 move)
		{
			float num = move[0];
			//float num = move[(int)(this.drive % DRIVE.ROT_X)];
			float value = custom.GetShape(this.shapeID) + num * this.Rate;
			custom.SetShape(this.shapeID, Mathf.Clamp01(value));
		}

		// Token: 0x0600099D RID: 2461 RVA: 0x000386D0 File Offset: 0x000368D0
		public void CustomMoveRot(CharaShapeCustomBase custom, Vector3 move)
		{
			float target = move[0];
			//float target = move[(int)(this.drive % DRIVE.ROT_X)];
			float value = custom.GetShape(this.shapeID) + Mathf.DeltaAngle(0f, target) * this.Rate;
			custom.SetShape(this.shapeID, Mathf.Clamp01(value));
		}

		// Token: 0x0600099E RID: 2462 RVA: 0x00038720 File Offset: 0x00036920
		public void CustomMoveScl(CharaShapeCustomBase custom, Vector3 move)
		{
			float num = move[0];
			//float num = move[(int)(drive % DRIVE.ROT_X)];
			float value = custom.GetShape(this.shapeID) + num * this.Rate;
			custom.SetShape(this.shapeID, Mathf.Clamp01(value));
		}

		// Token: 0x04000970 RID: 2416
		public int shapeID = -1;

		// Token: 0x04000971 RID: 2417
		public FemaleGuideCustom.MoveParam.DRIVE drive;

		// Token: 0x04000972 RID: 2418
		public float val;

		// Token: 0x02000171 RID: 369
		public enum DRIVE
		{
			// Token: 0x04000976 RID: 2422
			POS_X,
			// Token: 0x04000977 RID: 2423
			POS_Y,
			// Token: 0x04000978 RID: 2424
			POS_Z,
			// Token: 0x04000979 RID: 2425
			ROT_X,
			// Token: 0x0400097A RID: 2426
			ROT_Y,
			// Token: 0x0400097B RID: 2427
			ROT_Z,
			// Token: 0x0400097C RID: 2428
			SCL_X,
			// Token: 0x0400097D RID: 2429
			SCL_Y,
			// Token: 0x0400097E RID: 2430
			SCL_Z
		}

		// Token: 0x02000172 RID: 370
		public enum TYPE
		{
			// Token: 0x04000980 RID: 2432
			POS,
			// Token: 0x04000981 RID: 2433
			ROT,
			// Token: 0x04000982 RID: 2434
			SCL
		}
	}

	// Token: 0x02000173 RID: 371
	[Serializable]
	public class MovePoint
	{
		// Token: 0x060009A0 RID: 2464 RVA: 0x0003879C File Offset: 0x0003699C
		public void Setup(GuidesManager guidesManager, CharaShapeCustomBase custom, Transform root)
		{
			foreach (FemaleGuideCustom.MoveParam moveParam in this.moveParams)
			{
				moveParam.Setup();
			}
			this.custom = custom;
			this.trans = Transform_Utility.FindTransform(root, this.transformName);
			if (this.trans != null)
			{
				this.drive = guidesManager.Add(this.trans, false);
				bool flag = false;
				bool flag2 = false;
				bool flag3 = false;
				foreach (FemaleGuideCustom.MoveParam moveParam2 in this.moveParams)
				{
					if (moveParam2.Type == FemaleGuideCustom.MoveParam.TYPE.POS)
					{
						this.params_pos.Add(moveParam2);
						flag = true;
					}
					if (moveParam2.Type == FemaleGuideCustom.MoveParam.TYPE.ROT)
					{
						this.params_rot.Add(moveParam2);
						flag2 = true;
					}
					if (moveParam2.Type == FemaleGuideCustom.MoveParam.TYPE.SCL)
					{
						this.params_scl.Add(moveParam2);
						flag3 = true;
					}
				}
				bool pos = this.drive.enablePos;
				bool rot = this.drive.enableRot;
				bool scl = this.drive.enableScl;
				if (flag)
				{
					this.drive.delegateMovePos = new GuideDriveManager.DelegateMovePos(this.DelegateMovePos);
				}
				else
				{
					pos = false;
				}
				if (flag2)
				{
					this.drive.delegateMoveRot = new GuideDriveManager.DelegateMoveRot(this.DelegateMoveRot);
				}
				else
				{
					rot = false;
				}
				if (flag3)
				{
					this.drive.delegateMoveScl = new GuideDriveManager.DelegateMoveScl(this.DelegateMoveScl);
				}
				else
				{
					scl = false;
				}
				this.drive.SetEnables(pos, rot, scl);
			}
			else
			{
				GlobalData.Debug_LogError("无参考玻恩：" + this.transformName);
			}
		}

		// Token: 0x060009A1 RID: 2465 RVA: 0x00038954 File Offset: 0x00036B54
		private void DelegateMovePos(Vector3 move)
		{
			foreach (FemaleGuideCustom.MoveParam moveParam in this.params_pos)
			{
				moveParam.CustomMovePos(this.custom, move);
			}
		}

		// Token: 0x060009A2 RID: 2466 RVA: 0x000389B8 File Offset: 0x00036BB8
		private void DelegateMoveRot(Quaternion move)
		{
			foreach (FemaleGuideCustom.MoveParam moveParam in this.params_rot)
			{
				moveParam.CustomMoveRot(this.custom, move.eulerAngles);
			}
		}

		// Token: 0x060009A3 RID: 2467 RVA: 0x00038A20 File Offset: 0x00036C20
		private void DelegateMoveScl(Vector3 move)
		{
			foreach (FemaleGuideCustom.MoveParam moveParam in this.params_scl)
			{
				moveParam.CustomMoveScl(this.custom, move);
			}
		}

		// Token: 0x04000983 RID: 2435
		public string transformName = string.Empty;

		// Token: 0x04000984 RID: 2436
		public FemaleGuideCustom.MoveParam[] moveParams;

		// Token: 0x04000985 RID: 2437
		private Transform trans;

		// Token: 0x04000986 RID: 2438
		private GuideDriveManager drive;

		// Token: 0x04000987 RID: 2439
		private CharaShapeCustomBase custom;

		// Token: 0x04000988 RID: 2440
		private List<FemaleGuideCustom.MoveParam> params_pos = new List<FemaleGuideCustom.MoveParam>();

		// Token: 0x04000989 RID: 2441
		private List<FemaleGuideCustom.MoveParam> params_rot = new List<FemaleGuideCustom.MoveParam>();

		// Token: 0x0400098A RID: 2442
		private List<FemaleGuideCustom.MoveParam> params_scl = new List<FemaleGuideCustom.MoveParam>();
	}
}
